package com.yc.sakuralxm.uestcscanning.tools;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by sakuraLxm on 2017/11/29.
 */

public class SharedPreferencesUtils {
    public  static  String KEY_UID="TX538QTMZHYYQ67YYBI1YYQ2Q";
    public  static  String KEY_TURE="TX538QTMZHYYQ67YYBI1YYQ2Q";
    private static final String PREFERENCES_NAME = "sakura";


    private  static  final  String DEVICE_PWD = "260795";

    /**
     * 保存 Token 对象到 SharedPreferences。
     *
     * @param context 应用程序上下文环境
     * @param token   Token 对象
     */
    public static void writeAccessToken(Context context, String token) {
        if (null == context || null == token) {
            return;
        }

        SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
        SharedPreferences.Editor editor = pref.edit();
        editor.putString(KEY_UID, token);
        editor.commit();
    }
    public static  String getWxAccessToken(Context context){
        if (null ==context)
            return null;
        SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
        return pref.getString(KEY_UID,"");

    }

    public static void writeTure(Context context, boolean b) {
        if (null == context ) {
            return;
        }

        SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
        SharedPreferences.Editor editor = pref.edit();
        editor.putBoolean(KEY_TURE, b);
        editor.apply();
    }


    public static  boolean getTure(Context context){
        if (null ==context)
            return false;
        SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
        return pref.getBoolean(KEY_TURE,false);

    }
}
